package org.water.base.entity;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;


/***
 * 实体抽象类，其他实体需要继承该类,id自增加
 * @author qzy
 *
 */
@MappedSuperclass
public abstract class AutoIdEntity extends AbstractEntity<Long> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;

	public AutoIdEntity() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * id自动增长
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	//@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="id",nullable=false)
	private Long id;

	@Override
    public Long getId() {
		if("".equals(id)) id=null;
        return id;
    }
	
    @Override
    public void setId(Long id) {
        this.id = id;
    }
}
